package c_observer.a_origin;

/**
 * Created by wug on 2016/6/15 0015.
 */
public class Car {

    /**
     * 燃油量
     */
    private int oilmass;
    /**
     * 汽车速度
     */
    private int speed;
    /**
     * 维持这个速度的时间
     */
    private int remainTime;

    public Car() {
        this.oilmass = 60000;
        this.speed = 0;
    }

    public void setSpeed() {
        speed = (int)(Math.random()*100);
    }

    public int getSpeed() {
        return speed;
    }

    public int getRemainTime() {
        return remainTime;
    }

    public void setRemainTime() {
        /**
         * 假设维持车速为5分钟以内的随机数
         */
        remainTime = (int)(Math.random()*300);
    }

    public int getRemainOil() {
        /**
         * 假设百公里油耗10L
         */
        oilmass -= 10000 * speed * remainTime/3600/100;
        return oilmass;
    }

    public void carController() {
        setSpeed();
        setRemainTime();
    }
}
